Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-8810] [SQL] Added several UDF unit tests for Spark SQL #7207

Closed
wants to merge 2 commits into from

Conversation

spirom
Copy link
Contributor

@spirom spirom commented Jul 3, 2015

One test for each of the GROUP BY, WHERE and HAVING clauses, and one that combines all three with an additional UDF in the SELECT.

(Since this is my first attempt at contributing to SPARK, meta-level guidance on anything I've screwed up would be greatly appreciated, whether important or minor.)

testData.sqlContext.udf.register("havingFilter", (n:Long) => { n > 5 })

val result =
testData.sqlContext.sql("SELECT g, SUM(v) as s FROM groupData GROUP BY g HAVING havingFilter(s)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we now prefer just having the dataset closer to the test case rather than putting them in TestData.

You can do something like this easily in each test case itself

val df = Seq(("red", 1), ("red", 2), ("blue", 10), ("green", 100), ("green", 200)).toDF("g", "v")
df.registerTempTable("groupData")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line exceeds 100 characters and the last test failure is due to this. @spirom , Could you add proper indentation here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@rxin
Copy link
Contributor

rxin commented Jul 3, 2015

Thanks - looks pretty good for the first patch!

There are just some minor style issues.

@rxin
Copy link
Contributor

rxin commented Jul 3, 2015

Jenkins, ok to test.

@sarutak
Copy link
Member

sarutak commented Jul 3, 2015

ok to test.

@SparkQA
Copy link

SparkQA commented Jul 3, 2015

Test build #36484 has finished for PR 7207 at commit 1a3c5ff.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • case class GroupData(g: String, v: Int)

@SparkQA
Copy link

SparkQA commented Jul 3, 2015

Test build #36512 has finished for PR 7207 at commit 6bbba9e.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@rxin
Copy link
Contributor

rxin commented Jul 4, 2015

Thanks - I've merged this in master.

@asfgit asfgit closed this in e92c24d Jul 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants